package com.multi.thread.chapter05.demo03;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class TimerTest01 {
	
	private static final SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	private static Timer timer = new Timer();
	
	static private class TimerTaskTest extends TimerTask {
		@Override
		public void run() {
			System.out.println("运行了，时间为:" + ft.format(new Date()));
		}
		
	}
	
	public static void main(String[] args) {
		try {
			TimerTaskTest task = new TimerTaskTest();
			System.out.println("当前时间：" + ft.format(new Date()));
			timer.schedule(task, 5000, 3000);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
